<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>PCMS内容管理系统</title>
<link href="<?php echo $_tpl['css']; ?>admin.css" rel="stylesheet" type="text/css" />
<script language="JavaScript">
	function wconfirm( id )
	{
		if ( id != undefined )
		{
			var ok = window.confirm( '将仅对没有生成过的内容进行生成，确认要操作?' );
			if ( ok )
			{
				location.href = 'generate_html.php?id=' + id;
			}
		}
	}

	function wconfirm2( id )
	{
		if ( id != undefined )
		{
			var ok = window.confirm( '将全部生成该栏目所有页面(包括已经生成过的页面，可能耗时较长)，确认要操作?' );
			if ( ok )
			{
				location.href = 'generate_html.php?id=' + id + '&rang=all';
			}
		}
	}

	function wconfirm3( id )
	{
		if ( id != undefined )
		{
			var ok = window.confirm( '将生成模板类型为 其它 的页面，确认要操作?' );
			if ( ok )
			{
				location.href = 'generate_html.php?id=' + id;
			}
		}
	}
</script>
</head>

<body style='width:98%;'>
<center><h3>生成文件</h3></center>
<center>
<?php
	if ( isset( $gen_result['success'] ) )
	{
		echo date( 'Y-m-d H:i:s' ) . ' 执行结果：';
		echo $gen_result['success'] === true ? '成功' : ( '失败。 原因：' . $gen_result['message'] );
	}
?>
</center>
<table width="40%" border="0" align="center" cellpadding="5" cellspacing="1">
	<tr>
		<td height="20" align="left" bgcolor="#000000"><span class="bold">栏目</span></td>
		<td height="20" align="left" bgcolor="#000000"><span class="bold">操作</span></td>
	</tr>
	<?php
	function get_cate_path( $id, $data )
	{
		$path = '';
		foreach ( $data as $index => $value )
		{
			if ( $id == $value['id'] )
			{
				if ( $value['parent_id'] != 0 )
				{
					$path = get_cate_path( $value['parent_id'], $data );
				}
				$path .= $value['ename'] . '/';
			}
		}

		return $path;
	}
	foreach ( $cate_data as $index => $value )
	{
		$bgcolor = $index % 2 ? '#323232' : '#272727';
		$cate_path = get_cate_path( $value['id'], $cate_data );
		$cate_path = preg_replace( '/\/$/', '', $cate_path )

	?>
	<tr>
		<td height="20" align="left" bgcolor="<?php echo $bgcolor; ?>"><?php echo str_repeat( '&nbsp;&nbsp;', $value['level'] ) . '<a href="'. config( 'domain.www' ) . $cate_path . '/index.htm?'. time() . '" target="_blank" title="浏览该栏目内容">' . $value['cname']; ?></a></td>
		<td height="20" align="left" bgcolor="<?php echo $bgcolor; ?>"><a href="javascript:wconfirm(<?php echo $value['id']; ?>);">新内容生成</a> &nbsp;&nbsp;&nbsp; <a href="javascript:wconfirm2(<?php echo $value['id']; ?>);">全部重新生成</a></td>
	</tr>
	<?php
	}
	?>
	<tr>
		<td height="20" align="left" bgcolor="#323232"><a href="<?php echo config( 'domain.www' ); ?>index.htm?<?php echo time(); ?>" target="_blank">首页</a></td>
		<td height="20" align="left" bgcolor="#323232"><a href="javascript:wconfirm('home');">生成</a> <font color="red">注意:其它栏目内容要先生成!</font></td>
	</tr>
	<tr>
		<td height="20" align="left" bgcolor="#323232">其它页面</td>
		<td height="20" align="left" bgcolor="#323232"><a href="javascript:wconfirm3('other');">生成</a></td>
	</tr>

<?php
	if ( isset( $bar ) )
	{
?>
	<tr>
		<td height="20" colspan="16" align="center" bgcolor="#000000">
			<table width="30%"><tr align="center"><td><a href="<?php echo $bar['first_link']; ?>">首页</a></td><td><a href="<?php echo $bar['prev_link']; ?>">上一页</a></td><td><?php echo $bar['current']; ?> / <?php echo $bar['page']; ?></td><td><a href="<?php echo $bar['next_link']; ?>">下一页</a></td><td><a href="<?php echo $bar['last_link']; ?>">尾页</a></td></tr></table>
		</td>
	</tr>
<?php
	}
?>
</table>
</body>
</html>